package com.sskj.gocoin.v.activity;

import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.sskj.gocoin.MyAppLication;
import com.sskj.gocoin.R;
import com.sskj.gocoin.R2;
import com.sskj.gocoin.common.App;
import com.sskj.gocoin.common.AppManager;
import com.sskj.gocoin.common.widget.ToolBarLayout;
import com.sskj.gocoin.p.activity.ZwPwdLoginPresenter;
import com.sskj.gocoin.utils.CheckUtil;
import com.sskj.gocoin.utils.ClickUtil;
import com.sskj.gocoin.utils.ToastUtil;
import com.sskj.gocoin.v.base.BaseActivity;

import butterknife.BindView;

/**
 * ProjectName：期权
 * DESC: (类描述)指纹密码登录
 * Created by hqf on 2018/10/26 16:36
 * updateName:(修改人名称)
 * updateTime:(修改时间)
 * updateDesc:(修改内容)
 */
public class ZwPwdLoginActivity extends BaseActivity<ZwPwdLoginPresenter> {

    @BindView(R2.id.pwd_toolbar)
    ToolBarLayout customToolbar;
    @BindView(R2.id.my_account_login)
    TextView account;
    @BindView(R2.id.pwd)
    TextView pwd;
    @BindView(R2.id.personal_login)
    Button personalLogin;
    @BindView(R2.id.pwd_text)
    EditText pwdText;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_zw_pwd_login;
    }

    @Override
    public ZwPwdLoginPresenter getPresenter() {
        return new ZwPwdLoginPresenter();
    }

    @Override
    protected void onViewBinding() {
        customToolbar.setTitle(App.INSTANCE.getString(R.string.loginpwd));
//        ClickUtil.click(customToolbar, () -> {
//            finish();
//        });
        customToolbar.setLeftButtonOnClickLinster(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        if (!TextUtils.isEmpty(MyAppLication.getMobile())) {
            account.setText((App.INSTANCE.getString(R.string.xmlactivity_login46) + MyAppLication.getMobile()));
        }
        ClickUtil.click(personalLogin, () -> {
            String personLogin = pwdText.getText().toString().trim();
            if (CheckUtil.isMobile(MyAppLication.getMobile()) || CheckUtil.isEmail(MyAppLication.getMobile())) {
                if (personLogin.length() >= 6 && personLogin.length() <= 20) {
                    mPresenter.checkPwdLogin(personLogin);
                } else {
                    ToastUtil.showShort(App.INSTANCE.getString(R.string.strLoginActivity200));
                }
            } else {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.strLoginActivity201));
            }
        });


    }

    public void loginSuccess() {
        AppManager.getAppManager().finishActivity(SecurityVerifyActivity.class);
        finish();
    }

}
